package com.example.demo.entity;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;

import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
 * @author 陶国庆
 *二手车公司TwoCompany2--------》二手车公司名录入名字 TwoCompany
 */
@Entity
public class TwoCompany2 {
	@Id
	@GeneratedValue
	@JsonIgnore			//作用是json序列化时将java bean中的一些属性忽略掉
	private Integer id;
	//二手车信息
	@ManyToOne
	private TwoCompany twoCompany;
	//信息返利
	private Float msage;
	/**
	 * 起始日期
	 */
	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@JsonIgnore
	private Date beginDate;
	/**
	 * 结束日期
	 */
	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@JsonIgnore
	private Date endDate;
	
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public TwoCompany getTwoCompany() {
		return twoCompany;
	}
	public void setTwoCompany(TwoCompany twoCompany) {
		this.twoCompany = twoCompany;
	}
	public Float getMsage() {
		return msage;
	}
	public void setMsage(Float msage) {
		this.msage = msage;
	}
	public Date getBeginDate() {
		return beginDate;
	}
	
	public void setBeginDate(Date beginDate) {
		this.beginDate = beginDate;
	}
	public Date getEndDate() {
		return endDate;
	}
	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}
	
	@Transient
	private Integer getTwoCompanyId() {
		return twoCompany==null?null:twoCompany.getId();
	}
	
	@Transient
	private String getName() {
		return twoCompany==null?null:twoCompany.getName();
	}
}
